package com.rj.core.validation;


import com.rj.core.validation.constraints.Between;
import com.rj.util.VerifyUtils;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @author YFX_RANLUBO
 */
public class BetweenValidator implements ConstraintValidator<Between, Object> {
    /**
     * 最小值
     */
    protected Object max;
    /**
     * 最大值
     */
    protected Object min;


    public BetweenValidator() {
    }

    @Override
    public void initialize(Between constraintAnnotation) {
        max = constraintAnnotation.max();
        min = constraintAnnotation.min();
    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
        return VerifyUtils.between(false, value, min, max);
    }


}